

//输入 day /time 分别获取 天精度时间和 秒精度的时间 都是String类型的
export function getDatetime(fmt) {
    var d = new Date();
    var year = d.getFullYear();
    var month = change(d.getMonth() + 1);
    var day = change(d.getDate());
    var hour = change(d.getHours());
    var minute = change(d.getMinutes());
    var second = change(d.getSeconds());

    function change(t) {
        if (t < 10) {
            return "0" + t;
        } else {
            return t;
        }
    }
    let time;
    if(fmt==='time'){
        time= year + '-' + month + '-' + day + ' '
            + hour + ':' + minute + ':' + second;
    }else if(fmt==='day') {
        time= year + '-' + month + '-' + day
    }
    return time;
}

export function method2() {
    // 方法2的逻辑
}